﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Utils;

namespace WebUI.Controllers
{
    public class MailController : BaseController
    {
        public ActionResult Send(string key, string from, string to, string subject, string body, string bcc)
        {
            EmailMessage message = new EmailMessage(HttpUtility.UrlDecode(from), 
                HttpUtility.UrlDecode(to), 
                HttpUtility.HtmlDecode(HttpUtility.UrlDecode(subject)), 
                HttpUtility.HtmlDecode(HttpUtility.UrlDecode(body)), 
                HttpUtility.UrlDecode(bcc), true); //true means don't change info inside EmailMesssage class
            if (key != GlobalUtilities.GetInstance().BackgroundTaskExecutionKey)
            {
                return Content("");
            }
            else
            {
                EmailService.Send(message);
                return Content("Done");
            }
        }

    }
}
